package cn.yuanqiao.archive.statistics.service.impl;

import cn.yuanqiao.archive.appManager.domain.TenantCategory;
import cn.yuanqiao.archive.appManager.mapper.TenantCategoryMapper;
import cn.yuanqiao.archive.appManager.service.ITenantSysConfigService;
import cn.yuanqiao.archive.statistics.domain.StatisticalConfiguration;
import cn.yuanqiao.archive.statistics.domain.YearReport;
import cn.yuanqiao.archive.statistics.mapper.StatisticalConfigurationMapper;
import cn.yuanqiao.archive.statistics.mapper.YearReportMapper;
import cn.yuanqiao.archive.statistics.service.IYearReportService;
import cn.yuanqiao.common.exception.ServiceException;
import cn.yuanqiao.common.utils.SecurityUtils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 年报统计Service业务层处理
 * 
 * @author xy
 * @date 2023-07-28
 */
@Service
public class YearReportServiceImpl implements IYearReportService 
{
    @Autowired
    private YearReportMapper yearReportMapper;
    @Autowired
    private StatisticalConfigurationMapper statisticalConfigurationMapper;
    @Autowired
    private TenantCategoryMapper tenantCategoryMapper;
    @Autowired
    private ITenantSysConfigService sysConfigService;

    /**
     * 查询年报统计
     *
     * @param id 年报统计主键
     * @return 年报统计
     */
    @Override
    public YearReport selectYearReportById(Long id)
    {
        return yearReportMapper.selectYearReportById(id);
    }

    /**
     * 查询年报统计列表
     *
     * @param yearReport 年报统计
     * @return 年报统计
     */
    @Override
    public List<YearReport> selectYearReportList(YearReport yearReport)
    {
        return yearReportMapper.selectYearReportList(yearReport);
    }

    /**
     * 新增年报统计
     *
     * @param yearReport 年报统计
     * @return 结果
     */
    @Override
    public int insertYearReport(YearReport yearReport)
    {
        //将原本删除
        yearReportMapper.deleteYearReport(yearReport);
        yearReport.setCreateId(SecurityUtils.getUserId());
        return yearReportMapper.insertYearReport(yearReport);
    }

    /**
     * 修改年报统计
     *
     * @param yearReport 年报统计
     * @return 结果
     */
    @Override
    public int updateYearReport(YearReport yearReport)
    {
        return yearReportMapper.updateYearReport(yearReport);
    }

    /**
     * 批量删除年报统计
     *
     * @param ids 需要删除的年报统计主键
     * @return 结果
     */
    @Override
    public int deleteYearReportByIds(Long[] ids)
    {
        return yearReportMapper.deleteYearReportByIds(ids);
    }

    /**
     * 删除年报统计信息
     *
     * @param id 年报统计主键
     * @return 结果
     */
    @Override
    public int deleteYearReportById(Long id)
    {
        return yearReportMapper.deleteYearReportById(id);
    }

    @Override
    public YearReport selectYearReportByYear(String year,String type) {
        return yearReportMapper.selectYearReportByYear(year+"",new YearReport().getTableName(),type);
    }

    @Override
    public Map statistics(String year) {
        String ybgqx = sysConfigService.selectConfigByKey("YBGQX");
        String dbgqx = sysConfigService.selectConfigByKey("BGQX");

        //统计
        //先获取配置的值
        StatisticalConfiguration statisticalConfiguration=statisticalConfigurationMapper.selectStatisticalConfigurationById(new StatisticalConfiguration().getTableName(),"0");
        if(statisticalConfiguration==null){
            throw new ServiceException("请先配置年报统计配置！");
        }
        String contents=statisticalConfiguration.getContents();
        com.alibaba.fastjson.JSONArray jsonArray= com.alibaba.fastjson.JSONArray.parseArray(contents);
        Map map=new HashMap();
        Map map1=new HashMap();
        //将里面的值转成map
        for(int i=0;i<jsonArray.size();i++){
            com.alibaba.fastjson.JSONObject jsonObject=jsonArray.getJSONObject(i);
            map.put(jsonObject.getString("name"),jsonObject.getString("value"));

        }
        DecimalFormat format = new DecimalFormat("0.00");//本例实现小数点后保留二位有效数字

        //获取配置
        //以卷为保管单位档案
        String C28_1=map.get("C28_1").toString();
        //以件为保管单位档案
        String C29_1=map.get("C29_1").toString();
        //文书类电子档案
        String C32_1=map.get("C32_1").toString();
        //数码照片
        String C34_1=map.get("C34_1").toString();
        //数字录音、数字录像
        String C36_1=map.get("C36_1").toString();
        //照片档案
        String C38_1=map.get("C38_1").toString();
        //录音磁带、录像磁带、影片档案
        String C39_1=map.get("C39_1").toString();
        //实物档案
        String C40_1=map.get("C40_1").toString();

        //开始统计
        Long count=0L;
        Long count1=0L;
        Long count2=0L;
        Long count3=0L;


        if(C28_1!=null&&!"".equals(C28_1)){
            String bgqx="";
            count=yearReportMapper.getJuanCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C28_1);
            count1=yearReportMapper.getJuanCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C28_1);
            map1.put("C28_1",count);
            map1.put("C28_2",count1);
            bgqx=ybgqx;
            count=yearReportMapper.getJuanCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C28_1);
            count1=yearReportMapper.getJuanCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C28_1);
            map1.put("C41_1",count);
            map1.put("C41_2",count1);
            bgqx=dbgqx;
            count=yearReportMapper.getJuanCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C28_1);
            count1=yearReportMapper.getJuanCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C28_1);
            map1.put("C53_1",count);
            map1.put("C53_2",count1);

        }
        if(C29_1!=null&&!"".equals(C29_1)){
            String bgqx="";
            count=yearReportMapper.getJianCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C29_1);
            count1=yearReportMapper.getJianCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C29_1);
            map1.put("C29_1",count);
            map1.put("C29_2",count1);
            bgqx=ybgqx;
            count=yearReportMapper.getJianCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C29_1);
            count1=yearReportMapper.getJianCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C29_1);
            map1.put("C42_1",count);
            map1.put("C42_2",count1);
            bgqx=dbgqx;
            count=yearReportMapper.getJianCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C29_1);
            count1=yearReportMapper.getJianCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C29_1);
            map1.put("C54_1",count);
            map1.put("C54_2",count1);

        }
        if(C32_1!=null&&!"".equals(C32_1)){
            String bgqx="";
            List<TenantCategory> categoryList=tenantCategoryMapper.getCategoryById(C32_1,new TenantCategory().getTableName());

            count=yearReportMapper.getJianCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C32_1);
            count1=yearReportMapper.getJianCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C32_1);
            //文件
            count2=0L;
            count3=0L;
            for(TenantCategory tenantCategory:categoryList){
                count2+=yearReportMapper.getDocumentCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),tenantCategory.getEfileTableName(),tenantCategory.getFileTableName());
                count3+=yearReportMapper.getDocumentCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),tenantCategory.getEfileTableName(),tenantCategory.getFileTableName());
            }
            Double count2d = Double.valueOf(count2)/1024/1024/1024;
            String count2f  = format.format(count2d);
            Double count3d = Double.valueOf(count3)/1024/1024/1024;
            String count3f  = format.format(count3d);
            map1.put("C32_1",count);
            map1.put("C32_2",count1);
            map1.put("C33_1",count2f);
            map1.put("C33_2",count3f);
            bgqx=ybgqx;
            count=yearReportMapper.getJianCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C32_1);
            count1=yearReportMapper.getJianCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C32_1);
            //文件
            count2=0L;
            count3=0L;
            for(TenantCategory tenantCategory:categoryList){
                count2+=yearReportMapper.getDocumentCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),tenantCategory.getEfileTableName(),tenantCategory.getFileTableName());
                count3+=yearReportMapper.getDocumentCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),tenantCategory.getEfileTableName(),tenantCategory.getFileTableName());
            }
            count2d = Double.valueOf(count2)/1024/1024/1024;
            count2f  = format.format(count2d);
            count3d = Double.valueOf(count3)/1024/1024/1024;
            count3f  = format.format(count3d);
            map1.put("C44_1",count);
            map1.put("C44_2",count1);
            map1.put("C45_1",count2f);
            map1.put("C45_2",count3f);
            bgqx=dbgqx;
            count=yearReportMapper.getJianCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C32_1);
            count1=yearReportMapper.getJianCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C32_1);
            //文件
            count2=0L;
            count3=0L;
            for(TenantCategory tenantCategory:categoryList){
                count2+=yearReportMapper.getDocumentCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),tenantCategory.getEfileTableName(),tenantCategory.getFileTableName());
                count3+=yearReportMapper.getDocumentCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),tenantCategory.getEfileTableName(),tenantCategory.getFileTableName());
            }
            count2d = Double.valueOf(count2)/1024/1024/1024;
            count2f  = format.format(count2d);
            count3d = Double.valueOf(count3)/1024/1024/1024;
            count3f  = format.format(count3d);
            map1.put("C56_1",count);
            map1.put("C56_2",count1);
            map1.put("C57_1",count2f);
            map1.put("C57_2",count3f);

        }
        if(C34_1!=null&&!"".equals(C34_1)){
            String bgqx="";
            List<TenantCategory> categoryList=tenantCategoryMapper.getCategoryById(C34_1,new TenantCategory().getTableName());

            count=yearReportMapper.getYSCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C34_1);
            count1=yearReportMapper.getYSCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C34_1);
            //文件
            count2=0L;
            count3=0L;
            for(TenantCategory tenantCategory:categoryList){
                count2+=yearReportMapper.getDocumentCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),tenantCategory.getEfileTableName(),tenantCategory.getFileTableName());
                count3+=yearReportMapper.getDocumentCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),tenantCategory.getEfileTableName(),tenantCategory.getFileTableName());
            }
            Double count2d = Double.valueOf(count2)/1024/1024/1024;
            String count2f  = format.format(count2d);
            Double count3d = Double.valueOf(count3)/1024/1024/1024;
            String count3f  = format.format(count3d);
            map1.put("C34_1",count);
            map1.put("C34_2",count1);
            map1.put("C35_1",count2f);
            map1.put("C35_2",count3f);
            bgqx=ybgqx;
            count=yearReportMapper.getYSCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C34_1);
            count1=yearReportMapper.getYSCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C34_1);
            //文件
            count2=0L;
            count3=0L;
            for(TenantCategory tenantCategory:categoryList){
                count2+=yearReportMapper.getDocumentCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),tenantCategory.getEfileTableName(),tenantCategory.getFileTableName());
                count3+=yearReportMapper.getDocumentCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),tenantCategory.getEfileTableName(),tenantCategory.getFileTableName());
            }
            count2d = Double.valueOf(count2)/1024/1024/1024;
            count2f  = format.format(count2d);
            count3d = Double.valueOf(count3)/1024/1024/1024;
            count3f  = format.format(count3d);
            map1.put("C46_1",count);
            map1.put("C46_2",count1);
            map1.put("C47_1",count2f);
            map1.put("C47_2",count3f);
            bgqx=dbgqx;
            count=yearReportMapper.getYSCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C34_1);
            count1=yearReportMapper.getYSCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C34_1);
            //文件
            count2=0L;
            count3=0L;
            for(TenantCategory tenantCategory:categoryList){
                count2+=yearReportMapper.getDocumentCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),tenantCategory.getEfileTableName(),tenantCategory.getFileTableName());
                count3+=yearReportMapper.getDocumentCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),tenantCategory.getEfileTableName(),tenantCategory.getFileTableName());
            }
            count2d = Double.valueOf(count2)/1024/1024/1024;
            count2f  = format.format(count2d);
            count3d = Double.valueOf(count3)/1024/1024/1024;
            count3f  = format.format(count3d);
            map1.put("C58_1",count);
            map1.put("C58_2",count1);
            map1.put("C59_1",count2f);
            map1.put("C59_2",count3f);

        }
        if(C36_1!=null&&!"".equals(C36_1)){
            String bgqx="";
            List<TenantCategory> categoryList=tenantCategoryMapper.getCategoryById(C36_1,new TenantCategory().getTableName());

            count=yearReportMapper.getYSCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C36_1);
            count1=yearReportMapper.getYSCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C36_1);
            //文件
            count2=0L;
            count3=0L;
            for(TenantCategory tenantCategory:categoryList){
                count2+=yearReportMapper.getDocumentCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),tenantCategory.getEfileTableName(),tenantCategory.getFileTableName());
                count3+=yearReportMapper.getDocumentCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),tenantCategory.getEfileTableName(),tenantCategory.getFileTableName());
            }
            Double count2d = Double.valueOf(count2)/1024/1024/1024;
            String count2f  = format.format(count2d);
            Double count3d = Double.valueOf(count3)/1024/1024/1024;
            String count3f  = format.format(count3d);
            map1.put("C36_1",count);
            map1.put("C36_2",count1);
            map1.put("C37_1",count2f);
            map1.put("C37_2",count3f);
            bgqx=ybgqx;
            count=yearReportMapper.getYSCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C36_1);
            count1=yearReportMapper.getYSCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C36_1);
            //文件
            count2=0L;
            count3=0L;
            for(TenantCategory tenantCategory:categoryList){
                count2+=yearReportMapper.getDocumentCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),tenantCategory.getEfileTableName(),tenantCategory.getFileTableName());
                count3+=yearReportMapper.getDocumentCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),tenantCategory.getEfileTableName(),tenantCategory.getFileTableName());
            }
            count2d = Double.valueOf(count2)/1024/1024/1024;
            count2f  = format.format(count2d);
            count3d = Double.valueOf(count3)/1024/1024/1024;
            count3f  = format.format(count3d);
            map1.put("C48_1",count);
            map1.put("C48_2",count1);
            map1.put("C49_1",count2f);
            map1.put("C49_2",count3f);
            bgqx=dbgqx;
            count=yearReportMapper.getYSCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C36_1);
            count1=yearReportMapper.getYSCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C36_1);
            //文件
            count2=0L;
            count3=0L;
            for(TenantCategory tenantCategory:categoryList){
                count2+=yearReportMapper.getDocumentCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),tenantCategory.getEfileTableName(),tenantCategory.getFileTableName());
                count3+=yearReportMapper.getDocumentCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),tenantCategory.getEfileTableName(),tenantCategory.getFileTableName());
            }
            count2d = Double.valueOf(count2)/1024/1024/1024;
            count2f  = format.format(count2d);
            count3d = Double.valueOf(count3)/1024/1024/1024;
            count3f  = format.format(count3d);
            map1.put("C60_1",count);
            map1.put("C60_2",count1);
            map1.put("C61_1",count2f);
            map1.put("C62_2",count3f);
        }
        if(C38_1!=null&&!"".equals(C38_1)){
            String bgqx="";
            count=yearReportMapper.getYSCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C38_1);
            count1=yearReportMapper.getYSCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C38_1);
            map1.put("C38_1",count);
            map1.put("C38_2",count1);
            bgqx=ybgqx;
            count=yearReportMapper.getYSCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C38_1);
            count1=yearReportMapper.getYSCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C38_1);
            map1.put("C50_1",count);
            map1.put("C50_2",count1);
            bgqx=dbgqx;
            count=yearReportMapper.getYSCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C38_1);
            count1=yearReportMapper.getYSCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C38_1);
            map1.put("C62_1",count);
            map1.put("C62_2",count1);

        }
        if(C39_1!=null&&!"".equals(C39_1)){
            String bgqx="";
            count=yearReportMapper.getYSCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C39_1);
            count1=yearReportMapper.getYSCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C39_1);
            map1.put("C39_1",count);
            map1.put("C39_2",count1);
            bgqx=ybgqx;
            count=yearReportMapper.getYSCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C39_1);
            count1=yearReportMapper.getYSCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C39_1);
            map1.put("C51_1",count);
            map1.put("C51_2",count1);
            bgqx=dbgqx;
            count=yearReportMapper.getYSCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C39_1);
            count1=yearReportMapper.getYSCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C39_1);
            map1.put("C63_1",count);
            map1.put("C63_2",count1);
        }
        if(C40_1!=null&&!"".equals(C40_1)){
            String bgqx="";
            count=yearReportMapper.getJianCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C40_1);
            count1=yearReportMapper.getJianCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C40_1);
            map1.put("C40_1",count);
            map1.put("C40_2",count1);
            bgqx=ybgqx;
            count=yearReportMapper.getJianCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C40_1);
            count1=yearReportMapper.getJianCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C40_1);
            map1.put("C52_1",count);
            map1.put("C52_2",count1);
            bgqx=dbgqx;
            count=yearReportMapper.getJianCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C40_1);
            count1=yearReportMapper.getJianCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C40_1);
            map1.put("C64_1",count);
            map1.put("C64_2",count1);
        }

        return map1;
    }

    @Override
    public Map archivesStatistics(String year) {

        //统计
        //先获取配置的值
        StatisticalConfiguration statisticalConfiguration=statisticalConfigurationMapper.selectStatisticalConfigurationById(new StatisticalConfiguration().getTableName(),"1");
        if(statisticalConfiguration==null){
            throw new ServiceException("请先配置年报统计配置！");
        }
        String contents=statisticalConfiguration.getContents();
        com.alibaba.fastjson.JSONArray jsonArray= JSONArray.parseArray(contents);
        Map map=new HashMap();
        Map map1=new HashMap();
        //将里面的值转成map
        for(int i=0;i<jsonArray.size();i++){
            JSONObject jsonObject=jsonArray.getJSONObject(i);
            map.put(jsonObject.getString("name"),jsonObject.getString("value"));

        }
        DecimalFormat format = new DecimalFormat("0.00");//本例实现小数点后保留二位有效数字

        //获取配置
        //以卷为保管单位档案
        String C96_1=map.get("C96_1").toString();
        //以件为保管单位档案
        String C98_1=map.get("C98_1").toString();
        //文书类电子档案
        String C484_1=map.get("C484_1").toString();
        //数码照片
        String C488_1=map.get("C488_1").toString();
        //数字录音、数字录像
        String C492_1=map.get("C492_1").toString();
        //照片档案
        String C497_1=map.get("C497_1").toString();
        //录音磁带、录像磁带、影片档案
        String C499_1=map.get("C499_1").toString();
        //微缩胶片
        String C120_1=map.get("C120_1").toString();
        //实物档案
        String C122_1=map.get("C122_1").toString();
        //新中国成立前档案	卷
        String C151_1=map.get("C151_1").toString();
        //新中国成立前档案	件
        String C153_1=map.get("C153_1").toString();
        //明清之前的档案
        String C155_1=map.get("C155_1").toString();
        //明清档案		卷
        String C157_1=map.get("C157_1").toString();
        //明清档案		件
        String C159_1=map.get("C159_1").toString();
        //民国档案			卷
        String C161_1=map.get("C161_1").toString();
        //民国档案			件
        String C163_1=map.get("C163_1").toString();
        //革命历史档案			卷
        String C165_1=map.get("C165_1").toString();
        //革命历史档案	件
        String C167_1=map.get("C167_1").toString();
        //新中国成立后档案				卷
        String C169_1=map.get("C169_1").toString();
        //新中国成立后档案		件
        String C171_1=map.get("C171_1").toString();

        //开始统计
        Long count=0L;
        Long count1=0L;
        Long count2=0L;
        Long count3=0L;


        if(C96_1!=null&&!"".equals(C96_1)){
            count=yearReportMapper.getJuanCount((Integer.valueOf(year)-1)+"","",SecurityUtils.getTenantCode().toUpperCase(),C96_1);
            count1=yearReportMapper.getJuanCount((Integer.valueOf(year)-2)+"","",SecurityUtils.getTenantCode().toUpperCase(),C96_1);
            map1.put("C96_1",count);
            map1.put("C97_1",count1);
        }
        if(C98_1!=null&&!"".equals(C98_1)){
            String bgqx="";
            count=yearReportMapper.getJianCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C98_1);
            count1=yearReportMapper.getJianCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C98_1);
            map1.put("C98_1",count);
            map1.put("C99_1",count1);

        }
        if(C484_1!=null&&!"".equals(C484_1)){
            String bgqx="";
            List<TenantCategory> categoryList=tenantCategoryMapper.getCategoryById(C484_1,new TenantCategory().getTableName());

            count=yearReportMapper.getJianCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C484_1);
            count1=yearReportMapper.getJianCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C484_1);
            //文件
            count2=0L;
            count3=0L;
            for(TenantCategory tenantCategory:categoryList){
                count2+=yearReportMapper.getDocumentCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),tenantCategory.getEfileTableName(),tenantCategory.getFileTableName());
                count3+=yearReportMapper.getDocumentCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),tenantCategory.getEfileTableName(),tenantCategory.getFileTableName());
            }
            Double count2d = Double.valueOf(count2)/1024/1024/1024;
            String count2f  = format.format(count2d);
            Double count3d = Double.valueOf(count3)/1024/1024/1024;
            String count3f  = format.format(count3d);
            map1.put("C484_1",count);
            map1.put("C485_1",count1);
            map1.put("C486_1",count2f);
            map1.put("C487_1",count3f);

        }
        if(C488_1!=null&&!"".equals(C488_1)){
            String bgqx="";
            List<TenantCategory> categoryList=tenantCategoryMapper.getCategoryById(C488_1,new TenantCategory().getTableName());

            count=yearReportMapper.getYSCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C488_1);
            count1=yearReportMapper.getYSCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C488_1);
            //文件
            count2=0L;
            count3=0L;
            for(TenantCategory tenantCategory:categoryList){
                count2+=yearReportMapper.getDocumentCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),tenantCategory.getEfileTableName(),tenantCategory.getFileTableName());
                count3+=yearReportMapper.getDocumentCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),tenantCategory.getEfileTableName(),tenantCategory.getFileTableName());
            }
            Double count2d = Double.valueOf(count2)/1024/1024/1024;
            String count2f  = format.format(count2d);
            Double count3d = Double.valueOf(count3)/1024/1024/1024;
            String count3f  = format.format(count3d);
            map1.put("C488_1",count);
            map1.put("C489_1",count1);
            map1.put("C490_1",count2f);
            map1.put("C491_1",count3f);


        }
        if(C492_1!=null&&!"".equals(C492_1)){
            String bgqx="";
            List<TenantCategory> categoryList=tenantCategoryMapper.getCategoryById(C492_1,new TenantCategory().getTableName());

            count=yearReportMapper.getYSCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C492_1);
            count1=yearReportMapper.getYSCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C492_1);
            //文件
            count2=0L;
            count3=0L;
            for(TenantCategory tenantCategory:categoryList){
                count2+=yearReportMapper.getDocumentCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),tenantCategory.getEfileTableName(),tenantCategory.getFileTableName());
                count3+=yearReportMapper.getDocumentCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),tenantCategory.getEfileTableName(),tenantCategory.getFileTableName());
            }
            Double count2d = Double.valueOf(count2)/1024/1024/1024;
            String count2f  = format.format(count2d);
            Double count3d = Double.valueOf(count3)/1024/1024/1024;
            String count3f  = format.format(count3d);
            map1.put("C492_1",count);
            map1.put("C493_1",count1);
            map1.put("C494_1",count2f);
            map1.put("C495_1",count3f);

        }
        if(C497_1!=null&&!"".equals(C497_1)){
            String bgqx="";
            count=yearReportMapper.getYSCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C497_1);
            count1=yearReportMapper.getYSCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C497_1);
            map1.put("C497_1",count);
            map1.put("C498_1",count1);

        }
        if(C499_1!=null&&!"".equals(C499_1)){
            String bgqx="";
            count=yearReportMapper.getYSCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C499_1);
            count1=yearReportMapper.getYSCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C499_1);
            map1.put("C499_1",count);
            map1.put("C500_1",count1);
        }
        //
        if(C120_1!=null&&!"".equals(C120_1)){
            String bgqx="";
            count=yearReportMapper.getYSCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C120_1);
            count1=yearReportMapper.getYSCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C120_1);
            map1.put("C120_1",Double.valueOf(count)/10000);
            map1.put("C121_1",Double.valueOf(count1)/10000);
        }
        if(C122_1!=null&&!"".equals(C122_1)){
            String bgqx="";
            count=yearReportMapper.getJianCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C122_1);
            count1=yearReportMapper.getJianCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C122_1);
            map1.put("C122_1",count);
            map1.put("C123_1",count1);

        }
        if(C151_1!=null&&!"".equals(C151_1)){
            count=yearReportMapper.getJuanCount((Integer.valueOf(year)-1)+"","",SecurityUtils.getTenantCode().toUpperCase(),C151_1);
            count1=yearReportMapper.getJuanCount((Integer.valueOf(year)-2)+"","",SecurityUtils.getTenantCode().toUpperCase(),C151_1);
            map1.put("C151_1",count);
            map1.put("C152_1",count1);
        }
        if(C153_1!=null&&!"".equals(C153_1)){
            String bgqx="";
            count=yearReportMapper.getJianCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C153_1);
            count1=yearReportMapper.getJianCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C153_1);
            map1.put("C153_1",count);
            map1.put("C154_1",count1);

        }
        if(C155_1!=null&&!"".equals(C155_1)){
            String bgqx="";
            count=yearReportMapper.getJianCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C155_1);
            count1=yearReportMapper.getJianCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C155_1);
            map1.put("C155_1",count);
            map1.put("C156_1",count1);

        }
        if(C157_1!=null&&!"".equals(C157_1)){
            count=yearReportMapper.getJuanCount((Integer.valueOf(year)-1)+"","",SecurityUtils.getTenantCode().toUpperCase(),C157_1);
            count1=yearReportMapper.getJuanCount((Integer.valueOf(year)-2)+"","",SecurityUtils.getTenantCode().toUpperCase(),C157_1);
            map1.put("C157_1",count);
            map1.put("C158_1",count1);
        }
        if(C159_1!=null&&!"".equals(C159_1)){
            String bgqx="";
            count=yearReportMapper.getJianCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C159_1);
            count1=yearReportMapper.getJianCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C159_1);
            map1.put("C159_1",count);
            map1.put("C160_1",count1);

        }
        if(C161_1!=null&&!"".equals(C161_1)){
            count=yearReportMapper.getJuanCount((Integer.valueOf(year)-1)+"","",SecurityUtils.getTenantCode().toUpperCase(),C161_1);
            count1=yearReportMapper.getJuanCount((Integer.valueOf(year)-2)+"","",SecurityUtils.getTenantCode().toUpperCase(),C161_1);
            map1.put("C161_1",count);
            map1.put("C162_1",count1);
        }
        if(C163_1!=null&&!"".equals(C163_1)){
            String bgqx="";
            count=yearReportMapper.getJianCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C163_1);
            count1=yearReportMapper.getJianCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C163_1);
            map1.put("C163_1",count);
            map1.put("C164_1",count1);

        }
        if(C165_1!=null&&!"".equals(C165_1)){
            count=yearReportMapper.getJuanCount((Integer.valueOf(year)-1)+"","",SecurityUtils.getTenantCode().toUpperCase(),C165_1);
            count1=yearReportMapper.getJuanCount((Integer.valueOf(year)-2)+"","",SecurityUtils.getTenantCode().toUpperCase(),C165_1);
            map1.put("C165_1",count);
            map1.put("C166_1",count1);
        }
        if(C167_1!=null&&!"".equals(C167_1)){
            String bgqx="";
            count=yearReportMapper.getJianCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C167_1);
            count1=yearReportMapper.getJianCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C167_1);
            map1.put("C167_1",count);
            map1.put("C168_1",count1);

        }
        if(C169_1!=null&&!"".equals(C169_1)){
            count=yearReportMapper.getJuanCount((Integer.valueOf(year)-1)+"","",SecurityUtils.getTenantCode().toUpperCase(),C169_1);
            count1=yearReportMapper.getJuanCount((Integer.valueOf(year)-2)+"","",SecurityUtils.getTenantCode().toUpperCase(),C169_1);
            map1.put("C169_1",count);
            map1.put("C170_1",count1);
        }
        if(C171_1!=null&&!"".equals(C171_1)){
            String bgqx="";
            count=yearReportMapper.getJianCount((Integer.valueOf(year)-1)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C171_1);
            count1=yearReportMapper.getJianCount((Integer.valueOf(year)-2)+"",bgqx,SecurityUtils.getTenantCode().toUpperCase(),C171_1);
            map1.put("C171_1",count);
            map1.put("C172_1",count1);

        }

        return map1;
    }
}
